package com.lslk.othello.models;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class Preferences {
		public static final boolean DEFAULT_AI_WHITE=false;
		public static final boolean DEFAULT_AI_BLACK=false;
		public static final boolean DEFAULT_BLACK_FIRST=true;
		public static final String DEFAULT_TIME="500";
		
		public static final String TIME="0";
		public static final String WHITE="1";
		public static final String BLACK="2";
		public static final String FIRST="3";
    	
        private static SharedPreferences sPrefs = null;

        private static SharedPreferences getSharedPreferences(Context context) {
            if (sPrefs == null)  
            	sPrefs = PreferenceManager.getDefaultSharedPreferences(context);
            return sPrefs;
        }
        
        public static SharedPreferences.Editor getEditor(Context context) {
                getSharedPreferences(context);
                return sPrefs.edit();
        }

		public static boolean aiPlaysWhite(Context context) {
            	getSharedPreferences(context);
            	return sPrefs.getBoolean(WHITE,DEFAULT_AI_WHITE);
		}
		
		public static boolean aiPlaysBlack(Context context) {
            	getSharedPreferences(context);
            	return sPrefs.getBoolean(BLACK,DEFAULT_AI_BLACK);
		}
		
		public static boolean blackPlaysFirst(Context context) {
            	getSharedPreferences(context);
            	return sPrefs.getBoolean(FIRST,DEFAULT_BLACK_FIRST);
		}
        
		public static int getLimitInMilliseconds(Context context) {
            	getSharedPreferences(context);
            	return Integer.parseInt(sPrefs.getString(TIME,DEFAULT_TIME));
		}
}

